import http from '@/utils/http'

const BASE_URL = '/${moduleName}/${entityName}'

export interface ${EntityName}Resp {
<#if fieldConfigs??>
<#list fieldConfigs as fieldConfig>
  <#if fieldConfig.showInList>
  ${fieldConfig.fieldName}: string
  </#if>
</#list>
</#if>
}

export interface ${EntityName}DetailResp extends ${EntityName}Resp {
}

export interface ${EntityName}Query extends SortQuery {
<#if fieldConfigs??>
<#list fieldConfigs as fieldConfig>
  <#if fieldConfig.showInQuery>
  ${fieldConfig.fieldName}?: string
  </#if>
</#list>
</#if>
}

export interface ${EntityName}PageQuery extends ${EntityName}Query, PageQuery {

}

/** @desc 查询${businessName}列表 */
export function getPage(query: ${EntityName}PageQuery) {
  return http.get<Page<${EntityName}Resp[]>>(`${'$'}{BASE_URL}/page`, query)
}

/** @desc 查询${businessName}详情 */
export function getDetail(id: string) {
  return http.get<${EntityName}DetailResp>(`${'$'}{BASE_URL}/detail/${'$'}{id}`)
}

/** @desc 创建${businessName} */
export function create(data: any) {
  return http.post(`${'$'}{BASE_URL}/create`, data)
}

/** @desc 修改${businessName} */
export function update(data: any, id: string) {
  return http.post(`${'$'}{BASE_URL}/update/${'$'}{id}`, data)
}

/** @desc 删除${businessName} */
export function remove(ids: string | Array<string>) {
  return http.post(`${'$'}{BASE_URL}/delete/${'$'}{ids}`)
}
